from selenium import webdriver
from selenium.webdriver.chrome.options import Options


def selenium_Open_browser():
    """
    控制已经打开的浏览器，
    打开浏览器，cmd输入："C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="C:\selenum\AutomationProfile"
    确定浏览器路径在环境变量中。
    :return:
    """
    options = Options()
    options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
    chrome_driver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"
    driver = webdriver.Chrome(chrome_driver, options=options)
selenium_Open_browser()